<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//Dth HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'carType.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
		function toDingdan(carTypeNam,hourPrice,typeId){
				var date=$("#date").val();
				var nowDate=new Date().getTime();
				date=date.replace("年","/").replace("月","/").replace("日","")+":00";
				date=new Date(date).getTime();
				var diff=(date-nowDate)/(1000*60);
				if(diff<=60&&diff>0){
					$("#typeId").val(typeId);
					$("#typeName").val(carTypeNam);
					$("#hourPrice").val(hourPrice);
					$("#form1")[0].submit();
				}else{
					alert("必须预定一小时以内的车");
				}
				
				
		}
	</script>

  </head>
  
  <body>
  		<table>
  			<form action="carType/querOtherPrice" method="post" id="form1">
  				<input type="text" name="reserveHour.TerminalName" value="${deptName }" /><!-- 部门名称 -->
  				<input type="text" name="reserveHour.carTypeId" value="" id="typeId" />  <!--车型Id  -->
  				<input type="text" name="reserveHour.carType" value="" id="typeName" />  <!-- 车型名称 -->
  				<input type="text" name="reserveHour.carLocalId" value="${deptId }" />	<!-- 部门Id -->
  				<input type="text" name="reserveHour.usefencomid" value="${fenId }" />	<!-- 分公司ID -->
  				<input type="text" name="reserveHour.hourFee" value="" id="hourPrice" />	<!-- 时租价格 -->
  				<input type="text" name="reserveHour.clientName" value="小明"  />	<!-- 预定人 -->
  				<input type="text" name="reserveHour.clientId" value="62"  />	<!-- 预定人Id -->
  				<input type="text" name="reserveHour.clientPhone" value="15501080987" /> <!-- 预订人电话 -->
  				<input type="text" name="date" value="${date }" id="date"  />	<!-- 预定时间 -->
  			</form>
  			<tr>
  				<th>图片</th>
  				<th>车型/价格/地点</th>
  				<th>按钮</th>
  			</tr>
  			<c:forEach items="${carTypes }" var="carType">
  				<tr>
  					<td>
  						<img alt="" src="${carType.tcm_pic }">
  					</td>
  					<td>
  						${carType.tcm_wholeName }
  						${carType.fcbp_baseprice }元/小时
  						${deptName }
  					</td>
  					<td>
  						<c:if test="${carType.carCount>0 }">
  							<input type="button" value="租车" onclick="toDingdan('${carType.tcm_wholeName }',${carType.fcbp_baseprice },${carType.tcm_id });" />
  						</c:if>
  						<c:if test="${carType.carCount==0}">
  							<input type="button" value="租满" />
  						</c:if>
  					</td>
  				</tr>
  			</c:forEach>
  			
  		</table>
  </body>
</html>
